package com.apache.common;

import java.io.IOException;

import net.sf.json.JSONObject;

import com.apache.core.base.BaseAction;
import com.apache.core.web.struts2.Struts2Utils;

/**
 * 工作流Action基类
 * @author qmhao
 * @version 1.2.3
 */
@SuppressWarnings("serial")
public class FlowBaseAction extends BaseAction {

	/**
	 * 成功
	 * @param msg 成功提示信息
	 * @throws IOException 
	 */
	protected String showOk(Object msg) throws IOException {
		JSONObject jvo = new JSONObject();
		jvo.put("flag", "T");
		jvo.put("msg", msg);

		Struts2Utils.getResponse().setContentType("text/html;charset=UTF-8");
		Struts2Utils.getResponse().getWriter().write(jvo.toString());

		return null;
	}

	/**
	 * 失败
	 * @param msg 失败提示的文本信息
	 * @return
	 * @throws IOException String
	 */
	protected String showError(Object msg) throws IOException {
		net.sf.json.JSONObject jvo = new net.sf.json.JSONObject();
		jvo.put("flag", "F");
		jvo.put("msg", msg);

		Struts2Utils.getResponse().setContentType("text/html;charset=UTF-8");
		Struts2Utils.getResponse().getWriter().write(jvo.toString());

		return null;
	}
}
